#!/bin/sh
#
# A minimal init script for htpdate

### BEGIN INIT INFO
# Provides:        htpdate
# Required-Start:  $network $remote_fs $syslog
# Required-Stop:   $network $remote_fs $syslog
# Default-Start:   2 3 4 5
# Default-Stop:
# Short-Description: Start htpdate daemon
### END INIT INFO


test -x /usr/bin/htpdate || exit 0

PIDFILE="/var/run/htpdate.pid"
SERVERS="www.linux.org www.freebsd.org"

# See how we were called.
case "$1" in
	start)
		echo "Starting HTTP Time Protocol daemon: htpdate"
		# Set the time first before daemonizing, because the time offset
		# might be too big for smooth time adjustment
		/usr/bin/htpdate -D -s -i $PIDFILE $SERVERS
		;;
	stop)
		echo "Stopping HTTP Time Protocol daemon: htpdate"
		if [ -f $PIDFILE ]
		then
			kill `cat $PIDFILE`
		else
			echo "$PIDFILE not found"
		fi
		rm -f $PIDFILE
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac

exit 0

# vi:set ts=4:
